package com.irdstudio.efp.cus.service.impl;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.cus.service.dao.CusIndivExtDao;
import com.irdstudio.efp.cus.service.domain.CusIndivExt;
import com.irdstudio.efp.cus.service.facade.CusIndivExtService;
import com.irdstudio.efp.cus.service.vo.CusIndivExtVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 个人客户信息拓展表
 *
 * @author liangcongming :2020/5/9 10:38
 * @version 0.1
 * @date 2020/5/9 10:38
 * @since 2020/5/9 10:38
 */
@Service("cusIndivExtService")
public class CusIndivExtServiceImpl implements CusIndivExtService, FrameworkService {

    private static Logger logger = LoggerFactory.getLogger(CusIndivExtServiceImpl.class);

    @Autowired
    private CusIndivExtDao cusIndivExtDao;


    /**
     * 新增操作
     * @param cusIndivExtVO
     * @return
     */
    @Override
    public int insert(CusIndivExtVO cusIndivExtVO) {
        int num = 0;
        try {
            CusIndivExt cusIndivExt = new CusIndivExt();
            beanCopy(cusIndivExtVO, cusIndivExt);
            num = cusIndivExtDao.insert(cusIndivExt);
        } catch (Exception e) {
            logger.error("新增数据发生异常!", e);
            num = -1;
        }
        logger.info("根据条件:" + cusIndivExtVO + "新增的数据条数为" + num);
        return num;
    }


    /**
     * 更新操作
     * @param cusIndivExtVO
     * @return
     */
    @Override
    public int updateByPk(CusIndivExtVO cusIndivExtVO) {
        int num = 0;
        try {
            CusIndivExt cusIndivExt = new CusIndivExt();
            beanCopy(cusIndivExtVO, cusIndivExt);
            num = cusIndivExtDao.updateByPk(cusIndivExt);
        } catch (Exception e) {
            logger.error("修改数据发生异常!", e);
            num = -1;
        }
        logger.info("根据条件:" + cusIndivExtVO + "修改的数据条数为" + num);
        return num;
    }

    @Override
    public List<CusIndivExtVO> queryCusByStatusByPage(CusIndivExtVO cusIndivExtVO) {
        return cusIndivExtDao.queryCusByStatusByPage(cusIndivExtVO);
    }
}
